package com.bianguo.android.bprinter.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bianguo.android.baselibrary.adapter.BaseRecyclerAdapter;
import com.bianguo.android.bprinter.R;
import com.bianguo.android.ioclibrary.annotations.BindView;

import java.util.ArrayList;

import jcifs.smb.SmbFile;

public class PrinterAdapter extends BaseRecyclerAdapter<SmbFile> {

    public PrinterAdapter(Context mContext, ArrayList<SmbFile> list) {
        super(mContext, list);
    }

    @Override
    public BaseViewHolder createHolder(@NonNull ViewGroup viewGroup, int viewType) {
        View view = inflater.inflate(R.layout.item_printer_layout, viewGroup, false);
        ViewHolder holder = new ViewHolder(view);
        holder.contentTv.setOnClickListener(v -> {
            if (onClickItemListener != null) {
                onClickItemListener.onClickItem(this, v, holder.getLayoutPosition(), 0);
            }
        });
        return holder;
    }

    @Override
    public void bindHolder(@NonNull BaseViewHolder baseViewHolder, int position) {
        ViewHolder holder = (ViewHolder) baseViewHolder;
        SmbFile smbFile = list.get(position);
        holder.contentTv.setText(smbFile.getName());
    }

    public static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.item_printer_content)
        TextView contentTv;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}
